package com.youbug.mall.order_oms.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.youbug.common.vo.QueryVo;
import com.youbug.mall.order_oms.entity.OmsOrder;
import com.youbug.mall.order_oms.service.IOmsOrderService;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springframework.web.bind.annotation.*;
import com.youbug.common.vo.R;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.List;

import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 订单 前端控制器
 * </p>
 *
 * @author youbug
 * @since 2024-07-09
 */
@RestController
@RequestMapping("/omsOrder")
public class OmsOrderController {
@Autowired
private IOmsOrderService omsOrderService;

    @PostMapping("/getOmsOrderPage")
    public R<IPage<OmsOrder>> getOmsOrderPage(@RequestBody QueryVo<OmsOrder> queryVo){

        IPage<OmsOrder> omsOrders = omsOrderService.getOmsOrderPage(queryVo);

        return R.ok(omsOrders);
    }

    @GetMapping("/getOmsOrderById/{id}")
    public R<OmsOrder> getOmsOrderById(@PathVariable Integer id){

        OmsOrder omsOrder = omsOrderService.getById(id);

        return R.ok(omsOrder);
    }

    @PostMapping("/add")
    public R<Boolean> add(@RequestBody OmsOrder omsOrder){

        boolean save = omsOrderService.save(omsOrder);

        return  R.ok(save);
    }

    @PostMapping("/update")
    public R<Boolean> update(@RequestBody OmsOrder omsOrder){

        boolean update = omsOrderService.updateById(omsOrder);

        return  R.ok(update);
    }

    @GetMapping("/delete/{id}")
    public R<Boolean> delete(@PathVariable Integer id){

        boolean remove = omsOrderService.removeById(id);

        return  R.ok(remove);
    }
}

